package com.googlecode.hypersphere.ws2ejb3.xml;

public class Link {

	private final String path;
	private final String id;

	public final String getPath() {
		return path;
	}

	public final String getId() {
		return id;
	}

	public Link(String file, String id) {
		this.path = file;
		this.id = id;
	}

	
	/**
	 * @param string
	 *            has to be in the form of 'filename#link'
	 * @return a Link with the properties file and id
	 */
	public final static Link createLink(String string) {
		if (!string.contains("#") && !string.startsWith("#")) {
			System.out.println("Wrong argument: "+ string);
			throw new IllegalArgumentException(
					"Argument has to be of the form 'filename#link'");
		}
		String file = string.substring(0, string.indexOf("#"));
		String id = string.substring(string.indexOf("#") + 1, string.length());
		return new Link(file, id);
	}

}
